package com.mkyong.stock;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="category", catalog="mkyong")
public class CategoryJoinTable implements java.io.Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer categoryId;
	private String name;
	private String desc;
	private Set<StockCategory> stockCategories = new HashSet<StockCategory>(0);
	
	public CategoryJoinTable() {
		// TODO Auto-generated constructor stub
	}
	
	public CategoryJoinTable(String name, String desc) {
		this.name = name;
		this.desc = desc;
	}
	
	public CategoryJoinTable(String name, String desc, Set<StockCategory> stockCategories) {
		// TODO Auto-generated constructor stub
		this.name = name;
		this.desc = desc;
		this.stockCategories = stockCategories;
	}

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="CATEGORY_ID",unique=true,nullable=false)
	public Integer getCategoryId() {
		return categoryId;
	}

	public void setCategoryId(Integer categoryId) {
		this.categoryId = categoryId;
	}

	@Column(name="NAME",nullable=false,length=10)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name="[DESC]",nullable=false)
	public String getDesc() {
		return desc;
	}
	
	public void setDesc(String desc) {
		this.desc = desc;
	}
	
	@OneToMany(fetch=FetchType.LAZY,mappedBy="pk.category")
	public Set<StockCategory> getStockCategories() {
		return stockCategories;
	}

	public void setStockCategories(Set<StockCategory> stockCategories) {
		this.stockCategories = stockCategories;
	}

}